package ApplicationStartTest.KafkaConnect.entry;

import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class Receiver {

    private Gson gson = new GsonBuilder().create();


    @KafkaListener(topics = {"${spring.kafka.template.default-topic}"})
    public void processMessage(ConsumerRecord<String, String> content){
        //consumerRecord 是标准的数据封装的数据类型
        Message m = gson.fromJson(content.value(), Message.class);
        System.out.println(m);
    }
}
